package chatserver.container;




import java.util.Date;

public class BanInfo {

    public String name;
    public String ip;
    public int ipSize;
    public Long expires;
    public String banner;

    public BanInfo(String name, String ip, int ipSize, long expires, String banner) {
        this.name = name;
        this.ip = ip;
        this.ipSize = ipSize;
        this.expires = expires;
        this.banner = banner;
    }

    public boolean isExpired() {
        Date d = new Date();
        return (d.getTime() / 1000) >= expires;
    }

    public int getTimeLeft() {
        Date d = new Date();
        return (int) (expires - (d.getTime() / 1000));
    }

    public byte[] getRawIp() {
        byte[] ret = new byte[4];

        try {
            String[] data = ip.split("\\.");
            for (int i = 0; i < 4 && i < data.length; i++) {
                ret[i] = Integer.valueOf(data[i]).byteValue();
            }
        } catch (Exception e) {
        }
        return ret;
    }
}
